﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="js/offlights.js"></script>
	<title>TvPlayer</title>
	<style type="text/css">
		body {
			 position:fixed;
			 top:0;
			 left:0;
			 right:0;
			 bottom:0;
			 z-index:2147483647;
			 background:black;
			 width:100%;
			 height:100%;
		}
	</style>
	<!-- 屏蔽WebView中的所有手势 -->
	<script type="text/javascript">
		document.body.addEventListener("touchstart", function(event) {
					event.preventDefault();
		},false);
	</script>
</head>

<body>
<div id="video">
	<div id="a1"></div>
</div>

<script type="text/javascript" src="ckplayer/ckplayer.js" charset="utf-8"></script>
<script type="text/javascript">

	// 从URL中获取播放地址
	function getSourceFromURL() {
		var str = location.href;
		var num = str.indexOf("?");
		if(num==-1) 
		{
			// 如果没有指定播放地址，在返回一个缺省的地址，这样方便测试
			return "rtmp://www.gggg-box.com.cn/multicast/CH06";
		}
		else
		{
			return str.substr(num+1);
		}
	}
	
	// 获取浏览器高度
	function getWebHeight()
	{
		var winHeight = 0;
		if(window.innerHeight) {
			winHeight = window.innerHeight;
		}
		else if((document.body) && (document.body.clientHeight)) {
			winHeight = document.body.clientHeight;
		}
		
		if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth){
			winHeight = document.documentElement.clientHeight;
		}
		
		winHeight = winHeight + 20;
		
		return winHeight;
	}
	
	// 获取浏览器的宽度
	function getWebWidth()
	{
		var winWidth = 0;
		if(window.innerWidth) {
			winWidth = window.innerWidth;
		}
		else if((document.body) && (document.body.clientWidth)) {
			winWidth = document.body.clientWidth;
		}
		
		if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth){
			winWidth = document.documentElement.clientWidth;
		}
		
		return winWidth;
	}
	
	//  控制视频播放容器尺寸
	function checkPlayerSize()
	{
		document.getElementById('video').style.height = getWebHeight() + 'px';
		document.getElementById('video').style.width = getWebWidth() + 'px';
		
		//alert("width=" + document.getElementById('video').style.width);
	}
	
	// 默认执行一次
	checkPlayerSize();
	
	// 获取播发器播放时的参数信息
	function ckplayer_status(str){
 		if(str=='video:play'){
 			var a=swfobject.getObjectById('ckplayer_a1').ckplayer_getstatus();
 			var status='';
 			for (var k in a){
 				status += k+":"+ a[k] + ' ';
 			}
 			alert(status);
 		}
 	} 
	
	var flashvars={
		f:getSourceFromURL(),	// 视频地址
		c:0,		// 否读取文本配置,0不是，1是
		b:0,		// 打开JS控制
		p:1			// 加载后直接播放
		};
	var params={bgcolor:'#000',allowFullScreen:true,allowScriptAccess:'always'};
	var attributes={id:'ckplayer_a1',name:'ckplayer_a1',menu:'false'};
	swfobject.embedSWF('ckplayer/ckplayer.swf', 'a1', '100%', '100%', '10.0.0','ckplayer/expressInstall.swf', flashvars, params, attributes);
	//CKobject.embedSWF('ckplayer/ckplayer.swf','a1','ckplayer_a1',getWebWidth(),getWebHeight(),flashvars,params);
	
	/* 设置宽高, 从这里可以控制显示比例的问题  */
	// swfobject.getObjectById('ckplayer_a1').ckplayer_wandh(50, 100);
	
	
	/*
	CKobject.embedSWF(播放器路径,容器id,播放器id/name,播放器宽,播放器高,flashvars的值,其它定义也可省略);
	下面三行是调用html5播放器用到的
	*/
	//var video=['http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4'];
	//var support=['iPad','iPhone','ios','android+false','msie10+false','webKit'];
	//CKobject.embedHTML5('video','ckplayer_a1',600,400,video,flashvars,support);
	
	// 窗口触发时改变尺寸
	//window.onresize = checkPlayerSize;
  </script>
</body>
</html>
